package com.unlcn.ils.erpInterfaces.service.buss.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.unlcn.ils.erpInterfaces.dao.mapper.DataExportMapper;
import com.unlcn.ils.erpInterfaces.dao.model.dto.VipcnDTO;
import com.unlcn.ils.erpInterfaces.service.buss.IDataExportService;
import com.unlcn.ils.erpInterfaces.service.util.BaseException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class DataExportServiceImpl extends ServiceImpl<DataExportMapper, VipcnDTO> implements IDataExportService {


    /**
     * 公众号
     */
    @Override
    public List<VipcnDTO> getVipcnExcel(Map<String, String> dto) {
        if (dto == null) {
            throw new BaseException("参数不能为空");
        }
        String timeStamp = dto.get("timeStamp");
        EntityWrapper<VipcnDTO> ew = new EntityWrapper<>();
        if (StringUtils.isNotBlank(timeStamp)) {
            ew.ge("to_char(DTSHIP)", new Date(Long.valueOf(timeStamp)));
        }
        ew.orderBy("DTSHIP", false);
        return baseMapper.selectListWithTime(ew);
    }
}
